feat: migrate room segment lookup to dedicated chats api#1616
feat: migrate room segment lookup to dedicated chats api#1616sweetmantech merged 2 commits intotestfrom
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 14 minutes and 53 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9054cd0990
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const baseUrl = apiOverride || NEW_API_BASE_URL; | ||
|
|
||
| return useQuery({ | ||
| queryKey: ["roomSegment", roomId], |
There was a problem hiding this comment.
Key room segment query by token and API base
The query function now depends on both accessToken and baseUrl, but the cache key only includes roomId. In React Query, if the user logs out/in in the same tab (or changes ?api= override) while roomId stays constant, the hook can reuse cached data for up to the 5-minute staleTime and skip refetching, which can show segment data fetched under a different auth/backend context. Add auth/backend scope to the key (or invalidate on token/base URL changes) so cached results cannot bleed across sessions/environments.
Useful? React with 👍 / 👎.
- Extract fetch to lib/chats/getChatSegment.ts (SRP) - Use getAccessToken from Privy SDK instead of useAccessToken hook (KISS) - Follows same pattern as useDeleteChat and useArtistFromRoom Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
useChatSegmentto dedicatedGET /api/chats/{id}/segmentuseAccessTokenuseApiOverridesegment_id) to existing hook contract (segmentId)app/api/roomSegment/route.tsValidation
pnpm exec eslint hooks/useChatSegment.tsrg -n "/api/roomSegment|roomSegment" --glob "!**/node_modules/**"